package com.gx.smart.construction.ui.home.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.gx.smart.base.BaseAdapter;
import com.gx.smart.construction.R;
import com.gx.smart.construction.databinding.ItemFunctionLayoutBinding;
import com.gx.smart.construction.ui.home.model.Function;

import javax.inject.Inject;

import dagger.hilt.android.qualifiers.ActivityContext;

/**
 * @author xiaosy
 * @create 2019-11-20
 * @Describe
 **/
public class FunctionAdapter extends BaseAdapter<Function, FunctionAdapter.ViewHolder> {

    @Inject
    public FunctionAdapter(@ActivityContext Context context) {
        super(context);
    }

    @Override
    protected int onBindLayout() {
        return R.layout.item_function_layout;
    }

    @Override
    protected ViewHolder onCreateHolder(View view) {
        ItemFunctionLayoutBinding binding =
                DataBindingUtil.inflate(LayoutInflater.from(mContext), onBindLayout(), (ViewGroup) view, false);
        return new ViewHolder(binding);
    }

    @Override
    protected void onBindData(ViewHolder holder, Function item, int position) {
        holder.dataBinding.setItem(item);
    }


    public class ViewHolder extends RecyclerView.ViewHolder {
        private ItemFunctionLayoutBinding dataBinding;

        ViewHolder(ItemFunctionLayoutBinding dataBinding) {
            super(dataBinding.getRoot());
            this.dataBinding = dataBinding;
        }
    }
}
